package org.vergil.core.designpattern.command;

/**
 * Created by vergil on 17-3-23.
 */
public class FunctionButton {

    private String name; //功能键名称
    private AbstractCommand command; //维持一个抽象命令对象的引用

    public FunctionButton(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    //为功能键注入命令
    public void setCommand(AbstractCommand command) {
        this.command = command;
    }

    //发送请求的方法
    public void onClick() {
        System.out.print("点击功能键：");
        command.execute();
        command.undo();
    }
}
